package com.threadmethod.sleep;

/**
 * @PackageName:com.threadmethod.sleep
 * @ClassName:SimpTimer
 * @Description: 使用线程休眠完成一个简易的计时器
 * @Author: zhangxiaoyu
 * @date 2020/11/19 16:46
 */
public class SimpTimer {

    public static void main(String[] args){
          //从60秒开始计时
          int remaining = 60;
          //读取mian方法的参数
          if(args.length==1){
              remaining = Integer.parseInt(args[0]);
          }
          
          while (true){
              System.out.println("Remaining:"+remaining);
              remaining--;
              
              if(remaining<0){
                  break;
              }
              
              try {
                  Thread.sleep(1000);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }

          }
         System.out.println("完成！！！"); 
    }
}
